package com.axjy.web;

import com.axjy.dto.SolvetaskMainDto;
import com.axjy.pojo.SolvetaskMain;
import com.axjy.service.SolvetaskMainService;
import com.axjy.service.vo.Pager;
import com.axjy.util.Log;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * Created by 83536 on 2018/1/31.
 */
@RestController
@RequestMapping("/skm/skm")
public class SolvetaskMainHandler {
    @Resource
    private SolvetaskMainService solvetaskMainService;

    @GetMapping("/skmShow")
    public Pager skmShow(@RequestParam(required = false,defaultValue = "0")Integer offset, @RequestParam(required = false,defaultValue = "4")Integer limit, @Param("dto")SolvetaskMainDto solvetaskMainDto){
        Pager pager=solvetaskMainService.searchPager(offset, limit, solvetaskMainDto);
        return pager;
    }
    @GetMapping("/ssskmShow")
    public Pager ssskmShow(@RequestParam(required = false,defaultValue = "0")Integer offset, @RequestParam(required = false,defaultValue = "4")Integer limit, @Param("dto")SolvetaskMainDto solvetaskMainDto){
        Pager pager=solvetaskMainService.searchPagerss(offset, limit, solvetaskMainDto);
        return pager;
    }
    @GetMapping("/sskmShow")
    public Pager sskmShow(@RequestParam(required = false,defaultValue = "0")Integer offset, @RequestParam(required = false,defaultValue = "4")Integer limit, @Param("dto")SolvetaskMainDto solvetaskMainDto){
        Pager pager=solvetaskMainService.searchPagers(offset,limit,solvetaskMainDto);
        return pager;
    }
    @RequestMapping("/add")
    public String add(SolvetaskMain solvetaskMain){
        String msg=null;
        try{
            msg="新增成功";
            solvetaskMainService.add(solvetaskMain);
        }catch (RuntimeException ex){
            msg="新增失败";
            Log.logger.error(msg,ex);
        }
        return msg;
    }
    @RequestMapping("/update")
    public String update(SolvetaskMain solvetaskMain){
        String msg=null;
        try{
            msg="修改成功";
            solvetaskMainService.update(solvetaskMain);
        }catch (RuntimeException ex){
            msg="修改失败";
            Log.logger.error(msg,ex);
        }
        return msg;
    }
    @RequestMapping("/updatet")
    public String updatet(Integer id) {
        String msg = null;
        try {
            msg = "执行成功";
            solvetaskMainService.updatet(id);
        } catch (RuntimeException ex) {
            msg = "执行失败";
            Log.logger.error(msg, ex);
        }
        return msg;
    }
}
